$("#add").click(function (e) { 
    addpro(e);
});

function addpro(e){

    var proname = $("#proname").val();
    var proprice = $("#proprice").val();
    var prointr = $("#prointr").val();
    var proamount=$("#proamount").val();
    var proclass = $("#proclass").val();
    var prourl = $("#prourl").val();

    $.ajax({
        type: "POST",
        url: SERVER_PATH + "/admin/addproduct",
        data: {
            "name": proname,
            "price": proprice,
            "introduction": prointr,
            "proAmount": proamount,
            "proClass": proclass,
            "imageUrl": prourl
        },
        xhrFields: {withCredentials: true},
        success: function (result) {
            if (result.status) {
                alertBox(result.data.message);
                return false;
            }
            alertBox("添加成功！", function() {
                window.location.href = "adminhome.html";
            });
        }
    });
    
}